package cn.zhuzicc;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhaoxiang
 * @version 1.0
 * @description
 * @Date 2021/2/9 20:58
 */
public class DateFormatThreadLocal {
    
    private final static ThreadLocal<DateFormat> df = new ThreadLocal<DateFormat>(){
        protected  DateFormat initialValue() {
            return new SimpleDateFormat("yyyyMMdd");
        }
    };

    public static Date convert(String source){
        Date date = new Date();
        try {
            date = df.get().parse(source);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return date;
    }
}
